interface State {
  luid: string
  count: number
}

const state: State = {
  luid: 'login',
  count: 0,
}

const getters: GetterTree<State, State> = {
  count(state) {
    return state.count++
  },
}

const mutations: MutationTree<State> = {
  ['MT_CHANGE_UIDS'](state, payload: { luid: string }): void {
    state.luid = payload.luid
  },
}

const actions: ActionTree<State, State> = {
  loginChangeUid({ commit, state, rootState }, payload: { luid: string }) {
    console.log('login-state:', state, 'rootState: ', rootState)

    setTimeout(() => {
      commit('MT_CHANGE_UIDS', payload)
    }, 2000)
  },
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
}
